﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using DataAccessComponents;
using BusinessLogicLayer;

namespace inzDesktop
{
    /// <summary>
    /// Interaction logic for windowListaOfert.xaml
    /// </summary>
    public partial class windowListaOfert : Window
    {
        public windowListaOfert()
        {
            InitializeComponent();
            inicjalizujZawartosc();
        }
        public Oferta Oferta { get; set; }

        public void inicjalizujZawartosc()
        {
            OfertaBL ofertaBL = new OfertaBL();

            dataGridListaOfert.ItemsSource = ofertaBL.pobierzListe();
        }

        private void buttonSzczegoly_Click(object sender, RoutedEventArgs e)
        {
            // Tworzenie obiektu nowego okna                      
            windowSzczegolyOferta window = new windowSzczegolyOferta();
            Oferta zaznaczonyOferta = (Oferta)dataGridListaOfert.SelectedItem;

            // Przekazywanie idklienta do nowego okna
            window.inicjalizujZawartosc(zaznaczonyOferta.Id_oferta);
            window.Show();
        }

        private void btnWybierz_Click(object sender, RoutedEventArgs e)
        {
            if (dataGridListaOfert.SelectedItem != null)
            {
                this.Oferta = dataGridListaOfert.SelectedItem as Oferta;
                DialogResult = true;
            }
        }

        private void btnAnuluj_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = false;
        }
    }
}
